<template>
  <div class="banner">
    <ul class="mui-table-view">
        <li class="mui-table-view-cell mui-media" v-for="item in newsList" :key="item.id">
            <router-link :to="'/home/newsInfo/'+item.id">
                <img class="mui-media-object mui-pull-left" :src="item.img_url">
                <div class="mui-media-body">
                    <h1>{{item.title}}</h1> 
                    <p class='mui-ellipsis'>
                        <span>发表时间：{{item.add_time | comment()}}</span>
                        <span>点击次数：{{item.click}}</span>  
                    </p>
                </div>
            </router-link>
        </li>
    </ul>
  </div>
</template>
<script>
    export default {
        data(){
            return {
                newsList:[]
            }
        },
        created(){
            this.getNewsList()
        },
        methods:{
            getNewsList(){
                this.$http.get('api/getnewslist').then((results)=>{
                    if(results.body.status==0){
                        this.newsList=results.body.message
                    }else{
                        alert('网络请求失败')
                    }
                })
            }
        }
    }
</script>
<style lang="scss" scoped>
    .banner{
        padding: 0 10px;
        h1{
            font-size: 14px;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        p{
            color: rgb(61, 151, 224);
            display: flex;
            justify-content:space-between;
            font-size: 12px;
            
        }
    }
</style>
